import request from '@/utils/request'
// 供应商管理 : Supplier ControllerShow/HideList OperationsExpand Operations
// GET /api/suppliers
// 按搜索条件分页查询

// PATCH /api/suppliers
// 根据供应商ID，修改供应商信息

// POST /api/suppliers
// 添加供应商

// PATCH /api/suppliers/state/{supplierId}
// 供应商启用或禁用

// DELETE /api/suppliers/{supplierId}
// 根据供应商ID删除供应商数据
export function addSuppliers(data) {
    return request({
      url: '/api/suppliers',
      method: 'post',
      data
    })
  }
  export function suppliersList(query) {
    return request({
      url: '/api/suppliers',
      method: 'get',
      params: query
    })
  }
  
  export function updateSuppliersState(id,data) {
    return request({
      url: `/api/suppliers/state/${id}?state=`+data,
      method: 'patch',
    //   data
    })
  }
  export function updateSuppliers(data) {
    return request({
      url: `/api/suppliers`,
      method: 'put',
      data
    })
  }
  export function deleteSupplier(id) {
    return request({
      url: `/api/suppliers/${id}`,
      method: 'delete'
    })
  }
  export function getSupplierInfo(id) {
    return request({
      url: `/api/suppliers/${id}`,
      method: 'get'
    })
  }
//   /api/bases/provinces
  export function getProvinces(){
    return request({
        url: '/api/bases/provinces',
        method: 'get'
      })
  }
  export function getCities(id){
    return request({
        url: '/api/bases/cities?provinceId='+id,
        method: 'get'
      })
  }
  export function getAreas(id){
    return request({
        url: '/api/bases/areas?cityId='+id,
        method: 'get'
      })
  }
//   POST /api/file/supplier_attachments/upload
export function upload(data){
    return request ({
        url:'/api/file/supplier_attachments/upload',
        method:'post',
        data
    })
}

/**课程进度管理 */
// 课程进度管理 : PO Course ControllerShow/HideList OperationsExpand Operations
// GET /api/po_courses
// 按搜索条件分页查询

// POST /api/po_courses
// 给PO添加课程

// PUT /api/po_courses
// 根据ID更新PO课程数据

// DELETE /api/po_courses/{id}
// 根据ID删除记录
export function courseListF(query) {
  return request({
    url: '/api/po_courses',
    method: 'get',
    params: query
  })
}
export function addCourses(data) {
  return request({
    url: '/api/po_courses',
    method: 'post',
    data
  })
}
export function updateCourses(data) {
  return request({
    url: '/api/po_courses',
    method: 'put',
    data
  })
}
export function delCourse(id) {
  return request({
    url: `/api/po_courses/${id}`,
    method: 'delete',
    
  })
}

// /api/po_courses/id 获取状态
export function getCourseStatus(id) {
  return request({
    url: `/api/po_courses/${id}`,
    method: 'get',
    
  })
}
// GET /api/pos
// 按搜索条件分页查询

// PUT /api/pos
// 根据ID更新PO数据

// GET /api/pos/{id}
// 根据ID查询PO详情

export function infoPos(id) {
  return request({
    url: `/api/pos/${id}`,
    method: 'get',
    
  })
}

export function infoPosCourses(id,data) {
  return request({
    url: `/api/pos/${id}/courses`,
    method: 'get',
    params:data
  })
}
export function delPos(id) {
  return request({
    url: `/api/pos/${id}`,
    method: 'delete',
    
  })
}
export function updatePos(data) {
  return request({
    url: `/api/pos`,
    method: 'put',
    data
  })
}
export function posList(query) {
  return request({
    url: '/api/pos',
    method: 'get',
    params: query
  })
}


export function contractsList(query) {
  return request({
    url: '/api/contracts',
    method: 'get',
    params: query
  })
}
// POST /api/contracts
// 添加新合同
export function addContract(data) {
  return request({
    url: '/api/contracts',
    method: 'post',
   data
  })
}
// PUT /api/contracts
// 根据ID更新新合同数据
export function updateContracts(data) {
  return request({
    url: `/api/contracts`,
    method: 'put',
    data
  })
}
// POST /api/po_courses
// PATCH /api/contracts/{id}
// 导入PO管理列表，生成PO
export function contractPO(id) {
  return request({
    url: `/api/contracts/${id}`,
    method: 'patch',
    
  })
}
export function delContract(id) {
  return request({
    url: `/api/contracts/${id}`,
    method: 'delete',
    
  })
}

export function poCourses(data){
  return request({
    url:'/api/po_courses',
    method:'patch',
    data
  })
}

export function suppliersById(id){
  return request({
    url:`/api/po_courses/${id}/suppliers`,
    method:'get'
  })
}

export function addPoCourseSupplier(data){
  return request({
    url:'/api/po_course_supplier',
    method:'post',
    data
  })
}
export function updatePoCourseSupplier(data){
  return request({
    url:'/api/po_course_supplier',
    method:'put',
    data
  })
}
export function delPoCourseSupplier(id){
  return request({
    url:`/api/po_course_supplier/${id}`,
    method:'delete'
  })
}

export function poSettlement(data){
  return request({
    url:'/api/supplier_settlement_details',
    method:'post',
    data
  })
}
///api/po_course_supplier 供应商分配总单
export function poCourseSupplierList(data){
  return request({
    url:'/api/po_course_supplier',
    method:'get',
    params:data
  })
}

//供应商附件信息
export function getSupplierAttach(supplierId){
  return request({
    url:`api/supplier_attachments?supplierId=`+supplierId,
    method:'get',
    // supplierId
  })
}

//删除验收单/api/supplier_attachments/{id}
// POST /api/file/course_acceptance_report/upload
export function delSupplierFile(id){
  return request({
    url:`/api/supplier_attachments/${id}`,
    method:'delete'
  })
}

export function getSupplierAttachInfo(data){
  return request({
    url:'/api/supplier_attachments',
    method:'get',
    params:data
  })
}

// POST /api/file/import_po_course